var cssTransform = (function(){
    var prefixes = 'transform webkitTransform mozTransform oTransform msTransform'.split(' ')
        , el = document.createElement('div')
        , cssTransform
        , i = 0
    while( cssTransform === undefined ){
        cssTransform = document.createElement('div').style[prefixes[i]] != undefined ? prefixes[i] : undefined
        i++
    }
    return cssTransform
})()

$(function() {
    FastClick.attach(document.body);
});

var $content = $('.content'),
    $headerItems = $('.header-item'),
    $contentItems =$('.content-item'),
    $win=$(window)

var curIndex = 0;
var scrollMap=[0,0,0,0]
$headerItems.click(function(){
    var $this = $(this)
    var index = $this.data('index')
    if(index == curIndex)return ;


    var top = $win.scrollTop();
    scrollMap[curIndex] = top;

    $headerItems.removeClass('active');
    $this.addClass('active')
    curIndex = index
    $content.removeClass('s0 s1 s2 s3')
        .addClass('s'+index)
    $win.scrollTop(scrollMap[curIndex]);

    //var height = $contentItems.eq(+index).height();
    //$content.height(height);

})
